#{extends 'home.html' /}

<!-- Skin CSS file -->
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.9.0/build/assets/skins/sam/skin.css">
<!-- Utility Dependencies -->
<script src="http://yui.yahooapis.com/2.9.0/build/yahoo-dom-event/yahoo-dom-event.js"></script> 
<script src="http://yui.yahooapis.com/2.9.0/build/element/element-min.js"></script> 
<!-- Needed for Menus, Buttons and Overlays used in the Toolbar -->
<script src="http://yui.yahooapis.com/2.9.0/build/container/container_core-min.js"></script>
<script src="http://yui.yahooapis.com/2.9.0/build/menu/menu-min.js"></script>
<script src="http://yui.yahooapis.com/2.9.0/build/button/button-min.js"></script>
<!-- Source file for Rich Text Editor-->
<script src="http://yui.yahooapis.com/2.9.0/build/editor/editor-min.js"></script>

<body class="yui-skin-sam">

<script type="text/javascript">
var editor = new YAHOO.widget.SimpleEditor('contents', {
	handleSubmit: false
})

editor._defaultToolbar.titlebar = false;
editor.render();

YAHOO.util.Event.on('Submit your idea', 'click', function() {
    //Put the HTML back into the text area
    editor.saveHTML();
 
    //The var html will now have the contents of the textarea
    var html = editor.get('element').value;
});

YAHOO.util.Event.on('Save as draft', 'click', function() {
    editor.saveHTML();
 	var html = editor.get('element').value;
});

YAHOO.util.Event.on('Delete draft', 'click', function() {
    editor.saveHTML();
 	var html = editor.get('element').value;
});

YAHOO.util.Event.on('msgform', 'submit', function(e){
	YAHOO.util.Event.stopEvent(e);
	editor.saveHTML();
});
</script>


<script type="text/javascript" src="@{'/public/javascripts/jquery.validate.js'}"></script> 
	<script type="text/javascript" src="@{'/public/javascripts/jquery.validate.min.js'}"></script> 
	<script type="text/javascript" src="@{'/public/javascripts/validation.js'}"></script> 
	
<h1 class="viewTitle">${draft.title}</h1> 

<div class="viewContent">
#{if flash.success}
		<h2 style="color:GREEN"> <img src="@{'public/images/tick-icon.png'}"/> ${flash.success}</h2>
		#{/if}


<label for="o">Organization:</label>
<a id="o" class="standardLink" href="@{Browse.viewOrganization(draft.topic.entity.organization.id)}">${draft.topic.entity.organization.name}</a><br/>
<label for="e">Entity:</label>
<a  id="e"class="standardLink" href="@{Browse.viewEntity(draft.topic.entity.id)}">${draft.topic.entity.name}</a><br/>
<label for="t">Topic:</label>
<a  id="t"class="standardLink" href="@{Browse.viewTopic(draft.topic.id)}">${draft.topic.name}</a>

<form id="viewDraftForm"action="@{ProfileController.editDraft()}">
		
<div class="formEntry">
	<div class="formLabel"><label for="title">Title:<label style="font-size:12px;color:RED">*</label> </label></div>
	<input type="text" name="title"value="${draft.title}" class="inputText" />
	<div class="clear"></div>
</div>

<div class="formEntry">
	<div class="formLabel">
	<label for="contents">Your idea:<label style="font-size:12px;color:RED">*</label> </label>
	</div>
	
	<div class="clear"></div>
	<textarea class="yui-skin-sam" name="content" id ="contents" rows="10" cols="95">${draft.content.raw()}</textarea>
	
</div>


	
			 <input type="hidden" name ="draftId" value="${draft.id}"/>
			<input type="submit" value ="Submit your idea" name="postButton" id="Submit your idea"/>
			<input type="submit" value ="Save as draft" name="draftButton" id="Save as draft"/>
			<input type="submit" value ="Delete draft" name ="deleteButton" id="Delete draft"/>
			</form>
	
</div>
</body>